<template>
  <view>
    <view class="mine-container">
      <!--顶部个人信息栏-->
      <view class="header-section">
        <view class="flex padding justify-between">
          <view class="flex align-center">
            <view v-if="!avatar" class="cu-avatar xl round bg-white">
              <view class="iconfont icon-people text-gray icon"></view>
            </view>
            <image v-if="avatar" :src="avatar" class="cu-avatar xl round" mode="widthFix">
            </image>
            <view v-if="!name" @click="handleToLogin" class="login-tip">
              点击登录
            </view>
            <view v-if="name" class="user-info">
              <view class="u_title flex-row">
                {{name}}
                <view v-if="userInfo.sex == 0" class="icon-nan flex-col"></view>
                <view v-elif="userInfo.sex == 1" class="icon-nv flex-col"></view>
              </view>
              <view class="flex-row">
                <view class="text-wrapper" style="background: RGBA(207, 234, 227, 1)"><text style="color: RGBA(64, 192, 90, 1)">信誉优秀</text></view>
                <view class="text-wrapper" style="background: RGBA(221, 231, 255, 1)"><text style="color: RGBA(34, 119, 255, 1)">99分</text> </view>
              </view>

            </view>
          </view>
          <view @click="handleToInfo" class="flex align-center settle_btn"></view>
        </view>
      </view>
      <!--服务信息-->
      <view class="content-section">
        <view class="mine-actions grid col-5 text-center">
          <view class="action-item" @click="handleJiaoLiuQun">
            <text>{{ userInfo.orderCount }}</text>
            <text class="text" style="color: rgba(153, 153, 153, 1)">派单</text>
          </view>
          <view class="action-item" @click="handleBuilding">
            <text>{{ userInfo.receiveCount }}</text>
            <text class="text" style="color: rgba(153, 153, 153, 1)">接单</text>
          </view>
          <view class="action-item" @click="handleBuilding">
            <text>{{ userInfo.dealCount }}</text>
            <text class="text" style="color: rgba(153, 153, 153, 1)">成交</text>
          </view>
          <view class="action-item" @click="handleBuilding">
            <text>{{ userInfo.followCount }}</text>
            <text class="text" style="color: rgba(153, 153, 153, 1)">关注</text>
          </view>
          <view class="action-item" @click="handleBuilding">
            <text>{{ userInfo.fansCount }}</text>
            <text class="text" style="color: rgba(153, 153, 153, 1)">粉丝</text>
          </view>
        </view>
      </view>
      <!--账户-->
      <view class="group_5 flex-row justify-between">
        <view class="image_4">账户余额</view>
        <view class="image-text_6 flex-row justify-between">
          <text class="text-group_3">{{ userInfo.balance }}</text>
          <view class="text-wrapper_3 flex-col">
            <text class="text_7">提现</text>
          </view>
        </view>
      </view>
      <!--服务信息-->
      <view class="">
        <view class="mine-actions grid col-2 text-center">
          <view class="action-item" @click="handleJiaoLiuQun">
            <text class="text">派单中</text>
          </view>
          <view class="action-item" @click="handleBuilding">
            <text class="text">接单中</text>
          </view>
        </view>
      </view>
    </view>
    <view>
      <mescroll-uni ref="mescrollRef" :fixed="false" @init="mescrollInit" @down="downCallback"
                    :down="downOption" :up="upOption" @up="upCallback">
        <order-card2 :list="tableData"/>
      </mescroll-uni>
    </view>
  </view>
</template>

<script>
import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
import OrderCard2 from "@/components/index/order-card2.vue";
import {listOrder} from "@/api/attend/order";

export default {
  components: {OrderCard2},
  mixins: [MescrollMixin],
  data() {
    return {
      name: this.$store.state.user.name,
      userInfo: {
        sex: 2,
        balance: 0.0,
        orderCount: 0,
        receiveCount: 0,
        dealCount: 0,
        followCount: 0,
        fansCount: 0
      },
      tabIndex: 0,
      tableData: [],
      downOption: {},
      upOption: {
        page: {
          num: 0,
          size: 10 // 每页数据的数量,默认10
        },
        noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
        empty: {
          tip: '~ 空空如也 ~'
        }
      }
    }
  },
  computed: {
    avatar() {
      return this.$store.state.user.avatar
    },
    windowHeight() {
      return uni.getSystemInfoSync().windowHeight - 50
    }
  },
  onShow() {
    let _that = this
    if (_that.mescroll) _that.mescroll.resetUpScroll()
  },
  methods: {
    handleToInfo() {
      this.$tab.navigateTo('/pages/mine/info/index')
    },
    handleToLogin() {
      this.$tab.reLaunch('/pages/login')
    },

    handleLogout() {
      this.$modal.confirm('确定注销并退出系统吗？').then(() => {
        this.$store.dispatch('LogOut').then(() => {
          this.$tab.reLaunch('/pages/index')
        })
      })
    },
    handleJiaoLiuQun() {
      this.$modal.showToast('QQ群：①133713780、②146013835')
    },
    handleBuilding() {
      this.$modal.showToast('模块建设中~')
    },
    /*下拉刷新的回调 */
    downCallback() {
      this.mescroll.resetUpScroll()
    },
    /* 上拉翻页 */
    upCallback(page) {
      let _that = this
      let data = {
        pageNo: page.num,
        pageSize: page.size,
        ..._that.screenInfo,
      }

      listOrder(data).then((res) => {
        console.log(res, 'res')
        _that.mescroll.endSuccess(res.rows.length);
        if (page.num == 1) _that.tableData = [];
        _that.tableData = _that.tableData.concat(res.rows); //追加新数据
      }).catch(err => {
        _that.mescroll.endErr();
      })
    },
  }
}
</script>

<style lang="scss">
page {
  background-color: #F4F2FB;

  .mine-container {
    width: 100%;
    height: 360px;
    background: white url("https://a-1319987989.cos.ap-guangzhou.myqcloud.com/images/db1c8086deb34fa29f4bf890a515d2de_mergeImage.png") no-repeat;
    background-size: 100%;
    border-radius: 22px;


    .header-section {
      margin: 15px 15px 5px 15px;
      padding: 45px 15px 5px 15px;
      color: white;


      .login-tip {
        font-size: 18px;
        margin-left: 10px;
      }

      .cu-avatar {
        border: 2px solid #eaeaea;

        .icon {
          font-size: 40px;
        }
      }

      .user-info {
        margin-left: 15px;

        .u_title {
          font-size: 18px;
          line-height: 30px;
        }
      }
    }

    .content-section {
      position: relative;


      .mine-actions {
        margin: 5px 15px;
        padding: 5px 0px;
        border-radius: 8px;
        //background-color: white;

        .action-item {
          .icon {
            font-size: 28px;
          }

          .text {
            display: block;
            font-size: 13px;
            margin: 8px 0px;
          }
        }
      }
    }

    .group_5 {
      background: linear-gradient(90deg, rgb(233, 241, 255) 0%, rgb(238, 233, 255) 100%), #FFFFFF;
      border-radius: 16rpx 8rpx 8rpx 16rpx;
      border: 2rpx solid #FFFFFF;
      border-top: 2px solid transparent; /* 透明边框，形成斜角 */
      border-bottom: 2px solid transparent; /* 透明边框，形成斜角 */

      margin: 16px 16px 16px 12px;
      padding: 10px 0px 10px 16px;

      .image_4 {
        margin: 8px 0;
        width: 51px;
        height: 12px;
        font-family: PingFangSC, PingFang SC;
        font-weight: 550;
        font-size: 14px;
        color: RGBA(72, 23, 217, 1);
        line-height: 20px;
        text-align: left;
        font-style: normal;
        white-space: nowrap;
      }

      .image-text_6 {

        .text-group_3 {
          margin-right: 12px;
          overflow-wrap: break-word;
          color: rgba(0, 0, 0, 0.85);
          font-size: 18px;
          font-family: DIN-Bold;
          font-weight: 700;
          text-align: right;
          white-space: nowrap;
          line-height: 28px;
        }

        .text-wrapper_3 {
          background: linear-gradient(270deg, #521DFF 0%, #2277FF 100%);
          border-radius: 8rpx;
          margin: 2px 0 2px 4px;
          padding: 3px 16px 4px 16px;

          .text_7 {
            overflow-wrap: break-word;
            color: rgba(255, 255, 255, 1);
            font-size: 12px;
            font-family: PingFangSC-Medium;
            font-weight: 500;
            text-align: left;
            white-space: nowrap;
            line-height: 17px;
          }
        }
      }
    }
  }
}


.settle_btn {
  margin: 18px 0 18px 55px;
  width: 28px;
  height: 28px;
  background: #FFFFFF url("~@/static/icon/icon-setting.svg") no-repeat;
  background-size: 16px;
  background-position: center;
  box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.02);
  border-radius: 14px;
}

.icon-nan {
  width: 14px;
  height: 14px;
  background: url("~@/static/icon/icon-nan.svg") no-repeat;
  background-size: 14px;
  background-position: center;
  margin: 5px;
}

.icon-nv {
  width: 14px;
  height: 14px;
  background: url("~@/static/icon/icon-nv.svg") no-repeat;
  background-size: 14px;
  background-position: center;
  margin: 5px;
}


.box-with-diagonal-border {
  position: relative;
  width: 200px;
  height: 100px;
  background-color: #fff;
  border: 2px solid #000;
  border-right: none; /* 移除原始边框的右侧 */
}


</style>
